package com.hongxun.modules.bss.service.impl;

import java.util.UUID;

import com.hongxun.modules.bss.entity.MyContent;

import com.hongxun.modules.bss.entity.ReOutMeterAndDev;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.hongxun.modules.bss.dao.DWorkContentDao;
import com.hongxun.modules.bss.entity.DWorkContentEntity;
import com.hongxun.modules.bss.service.DWorkContentService;



@Service("dWorkContentService")
public class DWorkContentServiceImpl implements DWorkContentService {
	@Autowired
	private DWorkContentDao dWorkContentDao;

	@Override
	public DWorkContentEntity queryObject(String guid){
		return dWorkContentDao.queryObject(guid);
	}
	
	@Override
	public List<DWorkContentEntity> queryList(Map<String, Object> map){
		return dWorkContentDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return dWorkContentDao.queryTotal(map);
	}
	
	@Override
	public void save(DWorkContentEntity dWorkContent){
        if(dWorkContent.getGuid()==null||dWorkContent.getGuid().equals("")) {

		    dWorkContent.setGuid(UUID.randomUUID().toString());
        }
		dWorkContentDao.save(dWorkContent);
	}
	
	@Override
	public void update(DWorkContentEntity dWorkContent){
		dWorkContentDao.update(dWorkContent);
	}
	
	@Override
	public void delete(String guid){
		dWorkContentDao.delete(guid);
	}
	
	@Override
	public void deleteBatch(String[] guids){
		dWorkContentDao.deleteBatch(guids);
	}
	@Override
	public List<MyContent> getContentsb(String  guid)
	{
		return dWorkContentDao.getContentsb(guid);
	}
	@Override
	public List<MyContent> getContentxl(String  guid)
	{
		return dWorkContentDao.getContentxl(guid);
	}
	@Override
	public List<MyContent> getContentyssb(String  guid)
	{
		return dWorkContentDao.getContentyssb(guid);
	}
	@Override
	public List<MyContent> getContentysxl(String  guid)
	{
		return dWorkContentDao.getContentysxl(guid);
	}

	@Override
	public List<MyContent> getContentWt(String  guid)
	{
		return dWorkContentDao.getContentWt(guid);
	}
	@Override
	public 	List<ReOutMeterAndDev> getMeterAndDevByPoint(String  ppguid)
	{
		return dWorkContentDao.getMeterAndDevByPoint(ppguid);
	}
	@Override
	public void insertOrReplaceOrDelete(List<DWorkContentEntity> entities) {
		for (DWorkContentEntity d : entities) {
			if (d.getWCDatastate().equals("删除")) {
				dWorkContentDao.delete(d.getGuid());
			} else {
				DWorkContentEntity dWorkContentEntity = dWorkContentDao.queryObject(d.getGuid());
				if (dWorkContentEntity == null) {
					dWorkContentDao.save(d);
				} else {
					dWorkContentDao.update(d);
				}
			}
		}
	}
}
